import axios from 'axios';
import vue from 'vue';
import { Loading } from 'element-ui';

const request = axios.create({
    baseURL:'http://www.changbaiqi.com:8970',
    timeout:5000,
})
//请求拦截器
request.interceptors.request.use(config=>{

    const token = localStorage.getItem('token')
    if(token){
        config.headers = { 
            "Authorization":`Bearer${token}`,
            ...config.headers,
        }
    }
    return config
},err=>{
    return Promise.reject(err)
})
//响应拦截器
request.interceptors.response.use(response=>{
    // const Loading =  Loading.service({
    //     lock:true,
    //     text:'加载中...',
    //     background:'raga(0,0,0,.7)'
    // })
//    setTimeout(() =>{
//     Loading.close()
//    },3000)
    return response
 
},err=>{
    return Promise.reject(err)
})
export default request